package com.example.persion.controller;


import com.example.persion.commmon.lang.Result;
import com.example.persion.pojo.User;
import com.example.persion.service.UserService;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author dushaoqin
 * @since 2022-05-21
 */
@RestController
@RequestMapping("/user")
public class UserController {


    @Autowired
    UserService userService;


//    后端需要进行认证之后 才可以对这个接口进行访问
    @RequiresAuthentication
    @GetMapping("/index")
    public Result index(){
        System.out.println("hello");
        User user = userService.getById(1L);
        return Result.succ(200,"操作成功",user);
    }

    @PostMapping("/save")
    public Result save(@Validated @RequestBody  User user){
        
        return Result.succ(user);
    }


}
